package com.yang.demo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;

import com.jaeger.library.StatusBarUtil;
import com.yang.demo.ActivityCollector;
import com.yang.demo.R;
import com.yang.demo.adapter.TextTagsAdapter5;
import com.yang.demo.util.Loader;
import com.yang.demo.util.rxbus.RxBus;
import com.yang.demo.util.rxbus.Subscribe;
import com.yang.demo.view.TagCloudView;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yangwenwen on 2018/4/1.
 * <p>
 * 生成报告页
 */
public class ReportActivity extends AppCompatActivity {

    @BindView(R.id.tag_cloud)
    TagCloudView tagCloudView;
    @BindView(R.id.bottom)
    LinearLayout linearLayout;

    private TextTagsAdapter5 adapter5;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.report_activity);
        ActivityCollector.addActivity(this);
        ButterKnife.bind(this);
        RxBus.get().register(this);
        StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.main_blue), 50);
        StatusBarUtil.setDarkMode(this);
        Loader.show(this, "正在为你生成报告...");

        //生成报告由3dview展示
        adapter5 = new TextTagsAdapter5(this, R.color.main_red);
        tagCloudView.setAdapter(adapter5);
        linearLayout.setVisibility(View.VISIBLE);
        Loader.stop();
    }

    @Subscribe(code = 1010)
    public void exit() {
        //进入结果页
        startActivity(new Intent(this, ResultActivity.class));
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        RxBus.get().unRegister(this);
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return false;
    }
}
